<template>
	<gui-page :refresh="true" @reload="reload" :loadmore="true" @loadmorefun="loadData"
		:apiLoadingStatus="apiLoadingStatus" ref="guipage">
		<template v-slot:gBody>
			<gui-a-header title="线上招聘会"></gui-a-header>
			<view class="post-list pad-post">
				<gui-empty v-if="noData">
					<template v-slot:img>
						<view class="gui-flex gui-rows gui-justify-content-center">
							<image class="nodata-img" src="../../static/image/no_curriculum_vitae.png" mode="widthFix">
							</image>
						</view>
					</template>
					<template v-slot:text>
						<text class="gui-text-small gui-block gui-text-center gui-margin-top gui-color-gray">暂无数据</text>
					</template>
				</gui-empty>
				<view class="policy-list bgfff">
					<view class="policy-item gui-flex" @click="jumpDetail(order)" v-for="(order, oIndex) in dataList" :key="oIndex">
						<view class="info gui-flex1">
							<view class="f26 c333 title qoverDot2">
								{{order.xsTitle}}
							</view>
							<view class="f22 stress mt10 c999">
								{{order.createTime}}
							</view>
						</view>
						<view class="policy-img">
							<gui-image
								:src="order.xsImg"
								:width="211" :height="140" borderRadius="5rpx"></gui-image>
						</view>
					</view>
				</view>
			</view>
		</template>
	</gui-page>
</template>

<script setup>
	import {
		ref,
		reactive,
		inject
	} from 'vue'
	import {
		onLoad
	} from '@dcloudio/uni-app'
	import {
		selectComOnlineRecruitListNew0428
	} from '@/api/app.js'
	const guipage = ref(null);
	const apiLoadingStatus = ref(false)
	const $u = reactive(inject('$u'))
	const reload = (isRelod = true) => {
		query.value.pageNum = 1;
		loadData(isRelod);
	}
	const query = ref({
		pageNum: 1,
		pageSize: 10,
		postName: ''
	})
	const noData = ref(false);
	const dataList = ref([])
	// 搜索框输入
	const inputting = (e) => {
		query.value.postName = e;
	}
	// 搜索框确认
	const confirm = (e) => {
		console.log(e);
		query.value.postName = e;
		reload(false);
	}
	// 搜索清空
	const clear = (e) => {
		query.value.postName = '';
		reload(false);
	}
	// 查询
	const loadData = (isReload) => {
		let queryParam = Object.assign(query.value, {})
		selectComOnlineRecruitListNew0428(queryParam).then(res => {
			if (res.code == 200) {
				var resultArr = res.rows;
				let total = Math.ceil(res.total / queryParam.pageSize);
				if (queryParam.pageNum >= 2) {
					dataList.value = dataList.value.concat(resultArr);
					guipage.value.stoploadmore();
					if (queryParam.pageNum >= total) {
						guipage.value.nomore();
					}
				}else {
					dataList.value = [];
					dataList.value = resultArr;
					// 刷新
					if (isReload) {
						guipage.value.endReload();
					} else {
						guipage.value.stoploadmore();
					}
					(resultArr.length <= 0) ? noData.value = true: noData.value = false;
				}
				query.value.pageNum++;
			}
		})
	}
	
	onLoad(() => {
		loadData();
	})
	
	const jumpDetail = (item) => {
		uni.removeStorageSync('wurl')
		uni.setStorage({
			key: 'wurl',
			data: item.xsAddress,
			success: function () {
				$u.to(`/pages/webView/webView?pagetype=2`)
			}
		});
		
	}
	
</script>

<style lang="scss">
	.list {
		padding: 0 36rpx;
		margin-top: 10rpx;
	}
</style>